% TEST_ID: LANG-EXPAND-0107
% CATEGORY: language/string
% 测试 string 的字串提取

function test_string_extractBefore()

str = "The quick brown fox";
newStr = extractBefore(str,"quick ");
result = "The ";
assert_istrue(newStr, result);

str = ["The quick brown fox jumps";"over the lazy dog"];
newStr = extractBefore(str,["quick ";"the "]);
result = ["The "
    "over "];
assert_istrue(newStr, result);

str = "Edgar Allen Poe";
newStr = extractBefore(str,12);
result = "Edgar Allen";
assert_istrue(newStr, result);

str = ["Edgar Allen Poe";"Louisa May Alcott"];
newStr = extractBefore(str,[12;11]);
result = ["Edgar Allen"
    "Louisa May"];
assert_istrue(newStr, result);
end

function assert_istrue(x,y)
    assert(x == y);
end